package com.dff.jrfw.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.dff.jrfw.R;

public class ConfirmDialog extends Dialog {

    private TextView sure, cancle, tvTitle;
    private String content;

    public ConfirmDialog(@NonNull Context context, String content) {
        super(context, R.style.CustomDialog);
        this.content = content;
        setCanceledOnTouchOutside(false);   // 点击其他地方dialog不消失
        setCancelable(false);         // 点击返回键dialog不消失
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.confirm_dialog);
        tvTitle = findViewById(R.id.title);
        tvTitle.setText(content);
        sure = findViewById(R.id.sure);
        cancle = findViewById(R.id.cancle);
        sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
